package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.entity.AfshopComment;
import com.example.demo.mapper.AfshopCommentMapper;
import com.example.demo.service.IAfshopCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 会员评论表 服务实现类
 * </p>
 *
 * @author Mr.We
 * @since 2024-06-25
 */
@Service
public class AfshopCommentServiceImpl extends ServiceImpl<AfshopCommentMapper, AfshopComment> implements IAfshopCommentService {
    @Resource
    private AfshopCommentMapper afshopCommentMapper;

    @Override
    public AfshopComment queryObject(Integer id) {
        return afshopCommentMapper.queryObject(id);
    }

    @Override
    public List<AfshopComment> queryList(Map<String, Object> map) {
        return afshopCommentMapper.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return afshopCommentMapper.queryTotal(map);
    }

    @Override
    public int queryhasPicTotal(Map<String, Object> map) {
        return afshopCommentMapper.queryhasPicTotal(map);
    }

    @Override
    public boolean save(AfshopComment comment) {
        int result = afshopCommentMapper.insert(comment);
        return result > 0;
    }


    public void update(AfshopComment comment) {
        QueryWrapper<AfshopComment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", comment.getId());
        afshopCommentMapper.update(queryWrapper);
    }


    public void delete(Integer id) {
        QueryWrapper<AfshopComment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", id);
        afshopCommentMapper.delete(queryWrapper);
    }


    public void deleteBatch(Integer[] ids) {
        QueryWrapper<AfshopComment> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("id", (Object) ids);
        afshopCommentMapper.delete(queryWrapper);
    }
}
